<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<header th:replace="inc/header"></header>

<body th:with="menu='review'">
<nav th:replace="inc/nav"></nav>
<style>
	.treeview ul.list-group,.treeview0 ul.list-group{
		position:absolute;
		left: 80px;
    	top: -5px;
	}
	.treeview ul li.list-group-item,.treeview0 ul li.list-group-item{
		/* height:30px; */
		line-height:30px;
		padding: 0 15px;
		cursor:pointer;
	}
	.iscard .card-list a{
		line-height:2;
	}
	.search-title .dropdown-menu .divider{
		margin:0;
	}
</style>
<div class="container-fluid">
  <div class="row">
    <div th:replace="inc/sidebar"></div>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
      <h1 class="page-header">
        	心理评估结果查询
      </h1>
      <div class=" col-md-12 search-title">
      	<div class="col-md-10">
      		<div class="col-md-2" style="display:none;">
      			<span class="font-weight">监所编号：</span><span class="review-jsbh" th:text="${jsbh}"></span>
      		</div>

 			<div class="col-md-4">
				<span class="font-weight">人员：</span><input type="text" class="person" value="">
				
 			</div>
      		<div class="col-md-4">
      			<span class="font-weight">开始时间：</span><input type="text" name="datetime" class="ui_timepicker review-start-time" value="">
      		</div>
      		<div class="col-md-4">
      			<span class="font-weight">结束时间：</span><input type="text" name="datetime" class="ui_timepicker review-end-time" value="">
      		</div>
      	</div>
      
      	<div class="col-md-2 tableexportaddbtn">
          <a class="btn btn-primary btn-sm" id="btnSearch">查询</a>
        </div>
      </div>
      <table class="table table-striped searchList exportbtn">
        <thead>
        <tr>
          <th width="80">人员姓名</th>
          <th width="100">监室号</th>
          <th width="160">测试日期</th>
          <th>测试结果</th>
        </tr>
        </thead>
        <tbody>
        
        </tbody>
      </table>
    </div>
  </div>
</div>



<div th:replace="inc/footer"></div>
<div th:replace="inc/footer1"></div>
<script th:inline="javascript">
$(function () {
    $(".ui_timepicker").datetimepicker({
        showSecond: true,
        timeFormat: 'hh:mm:ss',
        stepHour: 1,
        stepMinute: 1,
        stepSecond: 1
    });
    $(".review-start-time").val(nowDate());
    $(".review-end-time").val(nowTime());

	//$(".exportbtn").tableExport({formats:["xlsx"],ignoreCols:6})
    $("#btnSearch").on("click",function (){
      btnSearchFn();
    });
    btnSearchFn();
    function btnSearchFn(){
      var reviewjsbh = $(".review-jsbh").text();

    	var person = $(".person").val();
    	var startTime = $(".review-start-time").val();
    	var endTime = $(".review-end-time").val();
    	startTime = startTime?"&startTime="+startTime:"";
    	endTime = endTime?"&endTime="+endTime:"";
		// http://localhost:8080/acp-cloud/assess/xl/resultQuery?rybh=1&jsbh=342601111&startTime=2019-02-09&endTime=2019-03-10
    	var searchUrl = "/acp-cloud/assess/xl/resultQuery?name="+person+"&jsbh="+reviewjsbh+startTime+endTime;
    	$.ajax({
    		url:searchUrl,
    		success:function (result){
    			console.log(result)
    			$(".searchList tbody").html('');
    			for(var i=0;i<result.length;i++){
        			var sjc = result[i].sjc;
        			if(sjc!=null){
        				sjc = changeTime(sjc);
        			}else{
        				sjc = "";
        			}
              var name = result[i].name||'';
					// 人员姓名、监室号、测试日期和测试结果  显示字段
        			$(".searchList tbody").append('<tr><td>'+name+'</td><td>'+result[i].jsh+'</td><td>'+sjc+'</td><td>'+result[i].csjg+'</td></tr>')
    				
    			}
    		}
    	})
		//$("caption").remove();
		//$(".exportbtn").tableExport({formats:["xlsx"]})
    	return false;
    }

	
	
	function nowDate(){
		var myDate = new Date();
		var y = myDate.getFullYear();    //获取完整的年份(4位,1970-????)
		var m = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
		m = m>9?m:"0"+m;
		var d = myDate.getDate();        //获取当前日(1-31)
		d = d>9?d:"0"+d;
		var date = y+"-"+m+"-"+d+" 00:00:00";
		return date;
	}

	function nowTime(){
		var myDate = new Date();
		var y = myDate.getFullYear();    //获取完整的年份(4位,1970-????)
		var m = myDate.getMonth()+1;       //获取当前月份(0-11,0代表1月)
		m = m>9?m:"0"+m;
		var d = myDate.getDate();        //获取当前日(1-31)
		d = d>9?d:"0"+d;
		var h = myDate.getHours();       //获取当前小时数(0-23)
		h = h>9?h:"0"+h;
		var ms = myDate.getMinutes();     //获取当前分钟数(0-59)
		ms = ms>9?ms:"0"+ms;
		var s = myDate.getSeconds();     //获取当前秒数(0-59)
		s = s>9?s:"0"+s;
		var time = y+"-"+m+"-"+d+" "+h+":"+ms+":"+s;
		return time;
	}
	function changeTime(time){
		var d = new Date(time);
		var mm = (d.getMonth() + 1)>9?(d.getMonth() + 1):"0"+(d.getMonth() + 1);
		var dd = (d.getDate())>9?(d.getDate()):"0"+(d.getDate());
		var hh = (d.getHours())>9?(d.getHours()):"0"+(d.getHours());
		var ms = (d.getMinutes())>9?(d.getMinutes()):"0"+(d.getMinutes());
		var ss = (d.getSeconds())>9?(d.getSeconds()):"0"+(d.getSeconds());
		var times=d.getFullYear() + '-' + mm + '-' + dd + ' ' + hh + ':' + ms + ':' + ss; 
		return times;
	}

})


</script>
</body>
</html>
